package magicloan.auctionpocket.adapter;

import android.app.Activity;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import magicloan.auctionpocket.R;
import magicloan.auctionpocket.bean.ProduceBean;

/**
 * Created by hechao on 2018/1/31.
 */
public class ThirdFgLeftRecylerAdapter extends BaseQuickAdapter<ProduceBean, BaseViewHolder> {

    private Activity mContext ;
    public ThirdFgLeftRecylerAdapter(@LayoutRes int layoutResId, @Nullable List<ProduceBean> data) {
        super(layoutResId, data);
    }

    public ThirdFgLeftRecylerAdapter(@Nullable List<ProduceBean> data) {
        super(data);
    }

    public ThirdFgLeftRecylerAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    public ThirdFgLeftRecylerAdapter(int layoutResId, Activity context) {
        super(layoutResId);
        mContext = context ;
    }

    private TextView mLastTv ;
    private View mLastView ;

    @Override
    protected void convert(BaseViewHolder helper, ProduceBean item, int position) {
        final View viewSelected = helper.getView(R.id.view_selected) ;
        final TextView tv_item_name = helper.getView(R.id.tv_item_name) ;
        helper.getView(R.id.root).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ( mLastTv!=null && mLastView!=null ){
                    mLastTv.setTextColor(mContext.getResources().getColor(R.color.color_999999));
                    mLastView.setVisibility(View.INVISIBLE);
                }
                viewSelected.setVisibility(View.VISIBLE);
                tv_item_name.setTextColor(mContext.getResources().getColor(R.color.color_333333));

                mLastTv = tv_item_name ;
                mLastView = viewSelected ;
            }
        });
    }

}
